package GUIadapter;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import ModelLayer.Order;

@SuppressWarnings("serial")
public class TableOrderAdapterModel extends AbstractTableModel
{
	private final String[] columnHeader= {"Navn", "Type", "Kunde", "Pris"};
	
	private List<Order> orderList;

	public TableOrderAdapterModel(List<Order> orderList)
	{
		this.orderList = orderList;
	}
	
	@Override
	public String getColumnName(int column)
	{
		// TODO Auto-generated method stub
		return columnHeader[column];
	}

	@Override
	public int getColumnCount()
	{
		// TODO Auto-generated method stub
		return columnHeader.length; //depends on amount of getters for a supplier eg.: "getName()"... very ugly
	}

	@Override
	public int getRowCount()
	{
		// TODO Auto-generated method stub
		return orderList.size();
	}

	@Override
	public Object getValueAt(int row, int col)
	{
		// TODO Auto-generated method stub
		Order order = orderList.get(row);
		switch(col)
		{
		case 0:
			return order.getOrdernr();
		case 1:
			return order.getDate();
		case 2:
			return order.getCustomer();
		case 3:
			return order.getTotalPrice();
		}
		return null; //should never reach here..!
	}

} //end TableSupplierAdapter
